#include <clusnet/base/CountDownLatch.h>
#include <gtest/gtest.h>

using namespace clusnet::base;

TEST(CountDownLatch, Test_countdown)
{
    CountDownLatch latch(2);
    ASSERT_EQ(latch.getCount(), 2);
    latch.countDown();
    ASSERT_EQ(latch.getCount(), 1);
    latch.countDown();
    ASSERT_EQ(latch.getCount(), 0);
    latch.wait();
    ASSERT_EQ(latch.getCount(), 0);
}

int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}
